//wow.js
function wowamd(){
wow = new WOW({
offset:100,          // default
mobile:true,       // default
live:true        // default
});
wow.init();
//wow 定义 start
$('[data-animated="fadeIn"]').addClass('wow animated fadeIn');
$('[data-animated="fadeInRight"]').addClass('wow animated fadeInRight');
$('[data-animated="fadeInDown"]').addClass('wow animated fadeInDown');
$('[data-animated="fadeInLeft"]').addClass('wow animated fadeInLeft');
$('[data-animated="fadeInUp"]').addClass('wow animated fadeInUp');
$('[data-animated="flipInX"]').addClass('wow animated flipInX');
$('[data-animated="zoomIn"]').addClass('wow animated zoomIn');
}
//wow 定义 end

//响应式导航
function navmobile(){
	//pad mobile nav
	$(".js_cf").on("click", function(me){
	var temp = $('.js_nav').is(":hidden");
	if(temp === true){
	$(this).addClass('c_nuw');
	$('.js_nav').delay(100).animate({left:'0'}, 200).css({'display':'block'});
	}else{
	$(this).removeClass('c_nuw');
	$('.js_nav').animate({left:'-100%'}, 200).fadeOut(200);	
	}
	$(document).one("click", function(){
	$(".js_cf").removeClass('c_nuw');
	$('.js_nav').animate({left:'-100%'}, 200).fadeOut(200);
	});
	me.stopPropagation();	
	});
	
	$(".js_nav").on("click", function(me){
	    me.stopPropagation();
	});
	//pad mobile nav  end !!!
}
//响应式导航判断
function navor(){
	if($(window).width() <= 750){ 
		$('.js_nav').animate({left:'-100%'}).hide();
	}else{
		$('.js_nav').animate({left:'0'}).css({'display':'block'});	
	}
}


//锚点事件
function smot() {
	$(".smooth").click(function() {
		var href = $(this).attr("href");
		var pos = $(href).offset().top - 184;
		$('html,body').animate({
			scrollTop: pos
		}, 1000);
		return false;
	});

	var stickyTop = $('.tznav').offset().top; //class当前高度
	$(window).scroll(function() {
		var scrollTop = $(window).scrollTop(); //浏览器当前高度
		if (scrollTop > stickyTop) {
			$(".tznav").addClass("fixedSubNav");
		} else {
			$(".tznav").removeClass("fixedSubNav");
		}
	})

}

//图片大小设置
function cotvimg() {
	$("img").each(function() {
		var imgwidth = $(this).width();
		var imgheight = $(this).height();
		var divwidth = $(this).parent().width();
		var divheight = $(this).parent().height();
		if (imgwidth > divwidth) {
			$(this).css({"height": "auto","max-width": "100%","max-height": ""});
			$(this).parent().addClass('h_imgflex');
		} else if (imgheight > divheight) {
			$(this).css({"width": "auto","max-height": "100%","max-width": ""});
			$(this).parent().addClass('h_imgflex');
		} else if (imgwidth > divwidth && imgheight > divheight) {
			$(this).css({"width": "100%","height": "100%","object-fit": "cover"});
		}
	});
}


//新闻详情页浮动
function newsleft() {
	var oftop = $('.container').offset().top;
	$('.xq_fl').addClass('fixed');
	var s = $(this).scrollTop();
	var h = $(document).height();
	var t = $(window).scrollTop();
	var wh = $(window).height();
	if (s >= oftop) {
		$('.xq_fl').addClass('fixed');
		$(".xq_fl.fixed").css("left", ($(window).width() - $(".container").width()) / 2)
		$('.xq_fl').css("top", "100px")
	} else {
		$('.xq_fl').removeClass('fixed');
	}
	if (h - t - wh <= $(".xq_tj").height()) {
		$('.xq_fl').removeClass('fixed');
	}
}
//news end


//模拟下拉
function select() {
	$(".select").each(function() {
		var s = $(this);
		var z = parseInt(s.css("z-index"));
		var dt = $(this).children("dt");
		var dd = $(this).children("dd");
		var _show = function() {
			dd.slideDown(200);
			dt.addClass("cur");
			s.css("z-index", z + 1);
		}; //展开效果
		var _hide = function() {
			dd.slideUp(200);
			dt.removeClass("cur");
			s.css("z-index", z);
		}; //关闭效果
		dt.click(function() {
			dd.is(":hidden") ? _show() : _hide();
		});
		dd.find("a").click(function() {
			dt.html($(this).html());
			_hide();
		}); //选择效果（如需要传值，可自定义参数，在此处返回对应的“value”值 ）
		$("body").click(function(i) {
			!$(i.target).parents(".select").first().is(s) ? _hide() : "";
		});
	});
}

//截取v值
function getv() {
	var getArgs = (function() {
		var host = "http://www.***.com";
		var sc = document.getElementsByTagName('script');

		var paramsA;
		for (var i = 0; i < sc.length; i++) {
			paramsA = sc[i].src;

			if (paramsA != "") {
				var paramsA = sc[i].src.split('?')[0];
				var paramsB = host + "/skin/js/main.js";
				if (paramsA == paramsB) {
					var paramsArr = sc[i].src.split('?')[1].split('&');
					//console.log(paramsArr);
				}
			}
		}
		v = paramsArr[0].split('=')[1];
	})();
}

//加入收藏
function addFavorite() {
	var url = window.location;
	var title = document.title;
	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf("msie 8") > -1) {
		external.AddToFavoritesBar(url, title, ''); //IE8
	} else {
		try {
			window.external.addFavorite(url, title);
		} catch (e) {
			try {
				window.sidebar.addPanel(title, url, ""); //firefox
			} catch (e) {
				alert("加入收藏失败，请使用Ctrl+D进行添加");
			}
		}
	}
}
//设为首页
function setHome(obj, vrl) {
	try {
		obj.style.behavior = 'url(#default#homepage)';
		obj.setHomePage(vrl);
	} catch (e) {
		if (window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			} catch (e) {
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage', vrl);
		}
	}
}
